html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  background-color: #ddd;
}

.container {
  width: 650px;
  margin: auto;
  h2 {
    text-align: center;
    margin-bottom: 60px;
  }
  button {
    outline: none;
    border: 1px solid #000;
    display: inline-block;
    width: 150px;
    background-color: transparent;
    box-sizing: border-box;
    position: relative;
    padding: 0;
    cursor: pointer;
    margin-right: 5px;
    span {
      display: block;
      padding: 10px;
      position: relative;
      z-index: 2;
      color: #fff;
    }
    &::before {
      content: "";
      position: absolute;
      transition: all 0.3s;
    }
    &::after {
      content: "";
      position: absolute;
      z-index: 1;
      transition: all 0.3s;
    }

    &.to-bottom {
      &::after {
        background-color: #000;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
      &:hover {
        span {
          color: #000;
        }
        &::after {
          height: 0;
        }
      }
    }
    &.to-top {
      &::after {
        background-color: #000;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
      &:hover {
        span {
          color: #000;
        }
        &::after {
          height: 0;
        }
      }
    }

    &.to-left {
      &::after {
        background-color: #000;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
      &:hover {
        span {
          color: #000;
        }
        &::after {
          width: 0;
        }
      }
    }
    &.to-right {
      &::after {
        background-color: #000;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
      }
      &:hover {
        span {
          color: #000;
        }
        &::after {
          width: 0;
        }
      }
    }
  }

  .two {
    margin: 60px 0;
    .line {
      padding: 5px;
      border: none;
      span {
        background-color: #000;
      }
      &.first {
        &::before {
          left: 0;
          top: 0;
          height: 10px;
          width: 10px;
          border-top: 1px solid #000;
          border-left: 1px solid #000;
        }
        &::after {
          right: 0;
          bottom: 0;
          height: 10px;
          width: 10px;
          border-bottom: 1px solid #000;
          border-right: 1px solid #000;
        }
      }

      &.second {
        &::before {
          right: 0;
          top: 0;
          height: 0;
          width: 0;
          border-top: 1px solid #000;
          border-left: 1px solid #000;
          transition: width 0.2s 0.2s, height 0.2s;
        }
        &::after {
          left: 0;
          bottom: 0;
          height: 0;
          width: 0;
          border-bottom: 1px solid #000;
          border-right: 1px solid #000;
          transition: width 0.2s 0.2s, height 0.2s;
        }
        &:hover {
          &::before,
          &::after {
            transition: width 0.2s, height 0.2s 0.2s;
          }
        }
      }

      &.third {
        &::before {
          right: 0;
          top: 0;
          height: 0;
          width: 0;
          border-top: 1px solid #000;
          border-left: 1px solid #000;
          transition: width 0.1s 0.3s, height 0.1s 0.2s;
        }
        &::after {
          left: 0;
          bottom: 0;
          height: 0;
          width: 0;
          border-bottom: 1px solid #000;
          border-right: 1px solid #000;
          transition: width 0.1s 0.1s, height 0.1s;
        }
        &:hover {
          &::before {
            transition: width 0.1s, height 0.1s 0.1s;
          }
          &::after {
            transition: width 0.1s 0.2s, height 0.1s 0.3s;
          }
        }
      }

      &:hover {
        &::before,
        &::after {
          width: 99%;
          height: 99%;
        }
      }
    }
  }

  .three {
    .blodline {
      border: none;
      background-color: #f5f5f5;
      span {
        color: #000;
      }
      &::before,
      &::after {
        content: "";
        height: 2px;
        background-color: #000;
        position: absolute;
      }
      &.first {
        &::before {
          width: 15%;
          right: 50%;
          bottom: 0;
          transition: width 0.2s 0.4s;
        }
        &::after {
          width: 15%;
          left: 50%;
          bottom: 0;
          transition: width 0.2s 0.4s;
        }
        &:hover {
          &::before,
          &::after {
            width: 50%;
            transition: width 0.2s;
          }
        }
        span {
          &::before,
          &::after {
            content: "";
            position: absolute;
            bottom: 0;
            opacity: 0;
            width: 0;
            height: 0;
            border-bottom: none;
            transition: width 0.2s, height 0.2s 0.2s, opacity 0.8s;
          }
          &::before {
            left: 0;
            border-left: 2px solid #000;
            border-top: 2px solid #000;
          }
          &::after {
            right: 0;
            border-right: 2px solid #000;
            border-top: 2px solid #000;
          }
          &:hover {
            &::before,
            &::after {
              opacity: 1;
              width: 50%;
              height: 100%;
              transition: width 0.2s 0.4s, height 0.2s 0.2s, opacity 0.1s;
            }
          }
        }
      }
      &.second {
        &::before,
        &::after {
          content: "";
          left: 0;
          width: 2px;
          background-color: #000;
          height: 30%;
          transition: height 0.2s 0.2s;
        }
        &::after {
          bottom: 50%;
        }
        &::before {
          top: 50%;
        }
        &:hover {
          &::before,
          &::after {
            height: 50%;
            transition: height 0.2s;
          }
        }
        span {
          &::before,
          &::after {
            content: "";
            position: absolute;
            width: 0;
            height: 0;
            left: 2px;
            opacity: 0;
            transition: width 0.2s 0.1s, height 0.1s, opacity 0.1s 0.2s;
          }
          &::before {
            top: 0;
            border-top: 2px solid #000;
            border-right: 2px solid #000;
          }
          &::after {
            bottom: 0;
            border-bottom: 2px solid #000;
            border-right: 2px solid #000;
          }
          &:hover {
            &::before,
            &::after {
              opacity: 1;
              width: calc(100% - 2px);
              height: 50%;
              transition: width 0.2s 0.2s, height 0.1s 0.4s, opacity 0.1s 0.2s;
            }
          }
        }
      }
    }
  }

  .four {
    margin-top: 30px;
    .opacity {
      background-color: #000;
      transition: all 0.8s;
      span {
        color: #fff;
      }
      &:hover {
        span {
          color: #000;
        }
        background-color: #fff;
      }
    }
  }
}
